﻿using CompanyRatings.PerfTest.Models.Query;
using CompanyRatings.SQL.PerfTest.ConsoleApp.Tests;
using PerfTestLib.Result;
using PerfTestLib.Spec;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompanyRatings.PerfTest.ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                int option;
                Console.WriteLine("0 - EXIT");
                Console.WriteLine("1 - SQL");
                Console.WriteLine("2 - SQL In-Mem OLTP");

                while(Int32.TryParse(Console.ReadLine(), out option) == false)
                {
                    Console.WriteLine("Incorrect option. Try again.");
                }

                TestSpecResult result = null;

                switch (option)
                {
                    case 0:
                        {
                            // EXIT
                        }
                        break;
                    case 1:
                        {
                            // disk test
                            CrDiskTest crDiskTest = new CrDiskTest();
                            result = crDiskTest.Run().Result;
                            Console.WriteLine("END OF - CR DISK TEST.");
                        }
                        break;
                    case 2:
                        {
                            // disk + mem test
                            CrDiskAndMemTest crDiskAndMemTest = new CrDiskAndMemTest();
                            result = crDiskAndMemTest.Run().Result;
                            Console.WriteLine("END OF - CR DISK + MEM TEST.");
                        }
                        break;
                }

                if (result != null && result.Exception != null)
                {
                    Console.WriteLine("ERROR OCCURRED:");
                    Console.WriteLine(result.Exception.ToString());
                }

                Console.WriteLine("END OF - ALL TESTS.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.ReadLine();
        }
    }
}
